<template>
  <div class="tab-control">
    <div
      v-for="(item, index) in title"
      class="tab-control-item"
      :key="index"
      :class="{ active: index == current }"
      @click="itemClcik(index)"
    >
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  data() {
    return {
      current: 0,
    };
  },
  methods: {
    itemClcik(index) {
      this.current = index;
      this.$emit("tabClick", index);
    },
  },
  props: {
    title: {
      type: Array,
      default() {
        return [];
      },
    },
  },
};
</script>

<style scoped>
.tab-control {
  display: flex;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background-color: #ffffff;
}

.tab-control-item {
  flex: 1;
}

.tab-control-item span {
  padding: 5px;
  font-weight: 700;
}

.active span {
  color: var(--color-high-text);
  border-bottom: 3px solid var(--color-tint);
}
</style>
